home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / L-M / MacOberon 4.0 / MacOberon™ 4.0 Folder / Automatic.Mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1993-10-25  |  1.4 KB  |  35 lines  |  [.Ob./.Ob5]

  1. Syntax10.Scn.Fnt
  2. Syntax10i.Scn.Fnt
  3. MODULE Automatic;    (* Michael Franz, 3.11.90 / 18.2.93 *)
  4.     A simple macro facility for executing several commands in succession.
  5.     Position the Star Marker in this viewer (Enter on Keypad)
  6.             Compiler.Compile *
  7.     Sample Activation:
  8.             Automatic.Do
  9.                 System.Directory *.Mod
  10.                 System.ShowCommands System ~
  11.                 Browser.ShowDef TextFrames ~
  12.     IMPORT
  13.         Texts, Oberon;
  14.         W: Texts.Writer;
  15.     PROCEDURE NextLine(text: Texts.Text; pos: LONGINT): LONGINT;
  16.         VAR R: Texts.Reader; ch: CHAR;
  17.     BEGIN
  18.         IF    pos < text.len    THEN    Texts.OpenReader(R, text, pos); Texts.Read(R, ch);
  19.             WHILE    ~R.eot & (ch#0DX)    DO    Texts.Read(R, ch)    END;
  20.             IF    R.eot    THEN    RETURN -1    ELSE    RETURN Texts.Pos(R)    END
  21.         ELSE    RETURN -1    END
  22.     END NextLine;
  23.     PROCEDURE Do*;
  24.         VAR S: Texts.Scanner; res: INTEGER;
  25.     BEGIN    Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
  26.         WHILE    S.class=Texts.Name    DO    Oberon.Par.pos:=Texts.Pos(S)-1;
  27.             Texts.WriteString(W, "Auto> "); Texts.WriteString(W, S.s); Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf);
  28.             Oberon.Call(S.s, Oberon.Par, FALSE, res); Oberon.Par.pos:=NextLine(Oberon.Par.text, Oberon.Par.pos);
  29.             IF    Oberon.Par.pos > 0    THEN    Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S)
  30.             ELSE    S.class:=Texts.Inval    END
  31.         END
  32.     END Do;
  33. BEGIN    Texts.OpenWriter(W)
  34. END Automatic.
  35.